from fastapi import APIRouter

from app.core.responses import Response
from app.services.ad import AdServices
from app.services.category import CategoryServices
from app.services.sservices import SServices

router = APIRouter(prefix="/home")


@router.get("/", summary="获取首页")
async def index():
    # 获取广告
    banner = AdServices.get_with_by_name('home_banner')
    # 获取链接
    link = AdServices.get_with_by_name('home_link')
    # 获取分类
    category = CategoryServices.get_all()
    # 获取套餐服务
    services = SServices.get_is_menu()
    data = {
        'banner': banner.ad_items.serialize(),
        'link': link.ad_items.serialize(),
        'category': category.serialize(),
        'menu_services': services.serialize()
    }
    return Response.success(data)
